Rework error handling#813
Conversation
|
you are the best! |
|
@craigbarratt If the overall direction doesn't feel right, I'm open to rethinking the main idea and exploring a different approach. |
|
Sorry about the delay in replying - I'm traveling. This looks excellent - a much better approach to let the native exception system do its job. I'm happy to merge this now, or should we wait a couple of weeks until we merge #795? |
|
I think it makes sense to merge this now. After that, I'll rebase/merge #795 and immediately apply the necessary architectural updates there. I also plan to make a couple of small follow-up changes after this PR. For #795, I can either merge it as a separate PR with a single commit to keep the history clean, or preserve the full commit history - whichever you prefer. What do you think? Thanks for reviewing this while traveling - really appreciate it. |
This is a major change in
Pyscriptcore. Please review it very carefully, especiallyast_try,ast_raise, andEvalFunc.call.Originally this was one large change, but I split it into smaller commits to make it easier to review. Each commit is consistent. Everything works and the tests pass.
Main idea:
finallywhere needed to restore contextException logging:
Initially, I planned to keep the old behavior and show only a single frame where the error occurred, but I ended up implementing a full traceback 🙂
EvalExceptionFormatter
tracebackmechanisms are used, with adjustments for user codelinenoandcol_offsetare taken fromast.expr/ast.stmt, which results in more precise error locationsTests:
There are many changes because the new mechanism closely matches native python behavior and is more precise.
Please pay attention to the last commit with exception chaining - it tests pyscript using pyscript itself.